# 插入排序：简单来说就是类似于扑克牌的起牌以及给牌排序阶段。我们主要就是把后面的元素一个一个的插入到前面的小列表中。

def insertionSort(alist):
    for index in range(1,len(alist)):

        currentvalue = alist[index] # 存储当前插入数据
        position = index
        while position > 0 and alist[position - 1] > currentvalue:
            alist[position] = alist[position-1]
            position = position - 1
        alist[position] = currentvalue

if __name__ == '__main__':
    alist = [54, 26, 93, 17, 77, 31, 44, 55, 20]
    insertionSort(alist)
    print(alist)